package it.poste.il.compensatore.entities;

import java.util.List;

import javax.persistence.CascadeType;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.OneToMany;
import javax.persistence.Table;

/**
 * Classe che modella l'entita' MessageStatus.
 */
@Entity
@Table(name="messagestatus")
public class MessageStatus extends BaseEntity {

	private static final long serialVersionUID = 1302661337791208655L;

	private String description;

	@OneToMany(fetch=FetchType.LAZY, cascade=CascadeType.ALL, mappedBy="statusId", targetEntity=Message.class)
	private List<Message> message;

	public String getDescription() {
		return description;
	}
	
	public void setDescription(String description) {
		this.description = description;
	}

	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result
				+ ((description == null) ? 0 : description.hashCode());
		result = prime * result + ((message == null) ? 0 : message.hashCode());
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		MessageStatus other = (MessageStatus) obj;
		if (description == null) {
			if (other.description != null)
				return false;
		} else if (!description.equals(other.description))
			return false;
		if (message == null) {
			if (other.message != null)
				return false;
		} else if (!message.equals(other.message))
			return false;
		return true;
	}

	@Override
	public String toString() {
		return this.getClass().getName() + " [id=" + getId() + ", description="
				+ description + "]";
	}

}
